
 /**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 * 
 */
package com.chinazyjr.framework.web.monitor.manager.logic;


 /**
 * <b>Description：</b> monitor监控 <br/>
 * <b>ClassName：</b> Node <br/>
 * <b>@author：</b> jackyshang <br/>
 * <b>@date：</b> 2016年8月25日 上午10:49:58 <br/>
 * <b>@version: </b>  <br/>
 */
public class MonitorZKNode {
    /**
     * 根节点.
     */
    public static final String PATH_ROOT = "/";
    //modify 
    //服务目录
//    public static final String PATH_PROVIDER_ROOT = PATH_ROOT + "/%s";
    public static final String PATH_PROVIDER_ROOT =  "/%s";

    public static final String NODE_PROVIDER_NAME = "providerName";
    //服务提供者名称
    public static final String PATH_PROVIDER_NAME = PATH_PROVIDER_ROOT + "/providerName";
    
    public static final String NODE_PROVIDER_DESC = "providerDesc";
    //服务提供者描述
    public static final String PATH_PROVIDER_DESC = PATH_PROVIDER_ROOT + "/providerDesc";

    public static final String NODE_PROVIDER_STATUS = "status";
  //服务提供者状态
    public static final String PATH_PROVIDER_STATUS = PATH_PROVIDER_ROOT + "/status";

    public  String getProviderRootPath(final String providerName) {
        return String.format(PATH_PROVIDER_ROOT, providerName);
    }

    
    
    public  String getProviderNamePath(final String providerName) {
        return String.format(PATH_PROVIDER_NAME, providerName);
    }

    public   String getProviderDescPath(final String providerName) {
        return String.format(PATH_PROVIDER_DESC, providerName);
    }
    
    public String getProviderStatusPath(final String providerName) {
        return String.format(PATH_PROVIDER_STATUS, providerName);
    }

    /**
     * 判断是否是status的路径
     * 
     * @param
     * @return boolean
     */
    public boolean isStatusNode(final String path) {
        return path.startsWith(PATH_ROOT) && path.endsWith(MonitorZKNode.NODE_PROVIDER_STATUS);
    }

    /**
     * 根据全路径截取某个提供者的
     * @param
     * @return String
     */
    public String genProviderPathByFull(String path) {
        String jobRoot = path.substring(0, path.lastIndexOf("/"));
        return jobRoot;
    }

    /**
     *根据全路径生成服务名称节点的全路径
     * @param
     * @return String
     */
    public String genProviderNamePathByFull(String path) {

        return genProviderPathByFull(path) + "/" + MonitorZKNode.NODE_PROVIDER_NAME;
    }


}
